/*wangp start*/
/*取消收藏*/
function doCancelCollect(collectionId,serverpath,dcc_index,i_c_columnid){ 
	if(confirm("确实要取消该收藏吗?")){
		$(".pop_cover").show();
    	$(".c_pop").show();
    	$("#quxiaoresult").html("正在操作请稍候...");
		 $.ajax({
		        type: "post",
		        dataType: "json",
		        url: serverpath+"/ajax/operation/doCancelCollect.action",
		        data: "collectionId="+collectionId,
		        success: function(root){
		            if(root == "success"){    
		            	$(".pop_cover").show();
		            	$(".c_pop").show();
		            	$("#quxiaoresult").html("取消收藏成功");
		            	setTimeout(function(){
		            		$(".pop_cover").hide();
		            		$(".c_pop").hide();
		            		if("index" == dcc_index){
			            		location.reload();
			            	}else{
			            		pageAjax('icenter_collectlist_div_'+i_c_columnid,'current_page=1&columnId='+i_c_columnid,serverpath+'/operation/queryCollectResources.action');
			            	}
		            	},3000);
		            } else{  
		            	common_a_div("取消收藏失败");
		            }
		        }
		 });
	}
}
/*提交评论*/
function addComment(serverpath,comment_add_resId){
	 var commentContent = $.trim($("#commentContent").val()); 
	 var commentGrade = $("#commentGrade").val();   
	 if(null == commentGrade || "" == commentGrade || undefined == commentGrade || "0" == commentGrade){
		 common_a_div("请选择星级");
		 return false;
	 }else if(null == commentContent || "" == commentContent || undefined == commentContent){
		 common_a_div("请输入评论内容");
		 return false;
	 }else if(commentContent.length < 3){
		 common_a_div("输入的评论内容不能少于3个字符，请重新输入");
		 return false;
	 }else if(commentContent.length > 100){
		 common_a_div("输入的评论内容不能超过100个字符，请重新输入");
		 return false;
	 }else{
		 $.ajax({
	        type: "post",
	        dataType: "json",
	        url: serverpath+"/ajax/comment/addComment.action",
	        data: "commentContent="+commentContent+"&commentGrade="+commentGrade+"&resId="+comment_add_resId,
	        success: function(root){
	            if(root == "success"){   
	        		common_a_div("评论已提交，审核通过后即可查看。"); 
	            } else if(root == "fail"){
	            	common_a_div("抱歉,评论失败。请稍后重试"); 
	            } else if(root == "nologin"){
	            	common_a_div("请登录后再评论"); 
	            }
	        }
	 	}); 
	}
}
function getGrade(grade){
	 $("#commentGrade").val(grade);
}

/*好友修改*/
function updateUserFriend(userFriendMobileOld,userFriendContent,userFriendId,userFriendMobile,userFriendPortalType,userFriendUserId,serverpath){
	 //非空判断
	if(null == userFriendMobile || "" == userFriendMobile || undefined == userFriendMobile){
		common_a_div("请输入手机号");
		return false;
	 }else if(userFriendMobile.length<11){ 
		common_a_div("手机号码有误");  
		return false;
	 }else{
		 $.ajax({
				url:serverpath+"/ajax/account/isMobile_Liantong.action",
				type:"post",
				data:"phone="+userFriendMobile,
				async:false,
				dataType:"json",
				success:function (root){   
				if(root == "success"){//是联通号    
					  if(null == userFriendContent || "" == userFriendContent || undefined == userFriendContent){
							 common_a_div("请输入备注名");
							 return false;
						  }else{
							 //号码是否相同
							 if(userFriendMobileOld==userFriendMobile ){
								 $.ajax({
								        type: "post",
								        dataType: "json",
								        url: serverpath+"/ajax/operation/requestUpdateUserFriend.action",
								        data: "userFriendContent="+userFriendContent+"&userFriendId="+userFriendId+"&userFriendMobile="+userFriendMobile+"&userFriendPortalType="+userFriendPortalType+"&userFriendUserId="+userFriendUserId,
								        success: function(root){
								            if(root == "success"){   
								        		common_a_div("修改成功"); 
								        		location.href=serverpath+"/usercenter/friend.3.jsp?page_at=friend";  
								            }else{
								            	common_a_div(root); 
								            } 
								        }
								 }); 
							 }else{
								//判断是否存在相同号码
								 $.ajax({
								        type: "post",
								        dataType: "json",
								        url: serverpath+"/ajax/operation/hasFriendMobile.action",
								        data: "mobile="+userFriendMobile,
								        success: function(root){
								            if(root == "fail"){
								            	 //修改操作
								            	 $.ajax({
								     		        type: "post",
								     		        dataType: "json",
								     		        url: serverpath+"/ajax/operation/requestUpdateUserFriend.action",
								     		        data: "userFriendContent="+userFriendContent+"&userFriendId="+userFriendId+"&userFriendMobile="+userFriendMobile+"&userFriendPortalType="+userFriendPortalType+"&userFriendUserId="+userFriendUserId,
								     		        success: function(root){
								     		            if(root == "success"){   
								     		        		common_a_div("修改成功"); 
								     		        		location.href=serverpath+"/usercenter/friend.3.jsp?page_at=friend";  
								     		            }else{
								     		            	common_a_div(root); 
								     		            } 
								     		        }
								     		 });
								            }else{ 
								            	common_a_div("好友手机号码已经存在，请勿重复保存"); 
								            } 
								        }
								 }); 
								 
							 }
						 }
				}else{
					common_a_div("请输入山东省内联通手机号码"); 
				   	return false;
				}	
			}
		 });  
		 
	 } 
}

/*删除好友*/
function delUserFriend(serverpath,delUserFriendID){  
	  if(confirm("确实要删除吗?")){
		 $.ajax({
		        type: "post",
		        dataType: "json",
		        url: serverpath+"/ajax/operation/requestDelUserFriend.action",
		        data: "delUserFriendID="+delUserFriendID,
		        success: function(root){
		            if(root == "success"){   
		        		common_a_div("删除成功"); 
		        		location.href=serverpath+"/usercenter/friend.3.jsp?page_at=friend";  
		            }else{
		            	common_a_div(root); 
		            	
		            } 
		        }
		 }); 
	  } 
}
/*邀请好友注册*/
function more_inviteFriend(friendMobile,serverpath){  
	 $.ajax({
	        type: "post",
	        dataType: "json",
	        url: serverpath+"/ajax/operation/requestInviteFriend.action",
	        data: "friendMobile="+friendMobile,
	        success: function(root){
	            if(root == "success"){   
	        		common_a_div("邀请信息已发送！");  
	            }else{
	            	common_a_div(root); 
	            } 
	        }
	 }); 
}
/*免费获取验证码     订购*/
function getOrderFreeCode(phone_div_name,reg_or_find,serverpath){ 
	var resourcesId=$("#orderId").val(); 
	if($("#orderfreeCode").html() != "免费获取验证码")return; 
	$.ajax({
		url:serverpath+"/ajax/operation/"+reg_or_find+".action",
		type:"post",
		data:"resourcesId="+resourcesId,
		async:false,
		dataType:"json",
		success:function (root){
		if(root == "success"){ 
		    //common_a_div("验证已下发您手机，请注意查收并完成！");
			mycount4();
		}else{
			//common_a_div(root);
			$("#desc").html(root); 
			$("#"+phone_div_name).focus();
			}
		}
	 });  
} 
/*wangp end*/


/*guop start*/

/* 短信分享 */
function doRecommend(serverpath,resourcesId,columnId,resType){
	var userMobile = $("#userMobile").val();
	var friendIds = "";
	if($(".recoList").html() != ""){
	    $("input[type='checkbox']").each(function(){
	    	if($(this).attr("checked")){
	    		friendIds+=$(this).attr("id")+",";
	    	}
		});
	}
	if((userMobile == "" || userMobile == null) && friendIds == ""){
		common_a_div("请输入或选择要推荐的好友手机号！");
	}else if(userMobile != "" && userMobile != null && userMobile.length != 11){
		common_a_div("手机号码有误"); 
	}else{
		if(userMobile != "" && userMobile != null){
			 $.ajax({
					url:serverpath+"/ajax/account/isMobile_Liantong.action",
					type:"post",
					data:"phone="+userMobile,
					async:false,
					dataType:"json",
					success:function (root){ 
						if(root == "success"){//是联通号
							//拼接用户输入的和选择的
							var fIds = "";
							if(friendIds != "" && userMobile != "" && userMobile != null){
								fIds = userMobile + "," + friendIds;
							}else{
								if(friendIds != ""){
									fIds = friendIds;
								}
								if(userMobile != ""){
									fIds = userMobile;
								}
							}
							$.ajax({
					 	        type: "post",
					 	        dataType: "json",
					 	        url: serverpath+"/ajax/operation/doRecommendR.action",
					 	        data: "columnId="+columnId+"&resourcesId="+resourcesId+"&friendMobiles="+fIds+"&resType="+resType,
					 	        success: function(root){ 
					 	            if(root == "true"){
					 	            	common_a_div("推荐成功！");
					 	            	//location.href=serverpath+"/login/login.3.jsp"; 
					 	            }else if(root == "noLogin"){
					 	            	common_a_div("您还没登陆！");
					 	            }else{
					 	            	common_a_div(root);
					 	            }
					 	        }
					    	 });
						}else{
							common_a_div("请输入山东省内联通手机号码");
						   	return false;
						}	
					}
			 });
		}else{
			var fIds = "";
			if(friendIds != ""){
				fIds = friendIds;
			}
			if(userMobile != ""){
				fIds = userMobile;
			}
			$.ajax({
	 	        type: "post",
	 	        dataType: "json",
	 	        url: serverpath+"/ajax/operation/doRecommendR.action",
	 	        data: "columnId="+columnId+"&resourcesId="+resourcesId+"&friendMobiles="+fIds+"&resType="+resType,
	 	        success: function(root){ 
	 	            if(root == "true"){
	 	            	common_a_div("推荐成功！");
	 	            	//location.href=serverpath+"/login/login.3.jsp"; 
	 	            }else if(root == "noLogin"){
	 	            	common_a_div("您还没登陆！");
	 	            }else{
	 	            	common_a_div(root);
	 	            }
	 	        }
	    	 });
		}
	}
}



/*guop end*/


/*yuany start*/




/*yuany end*/



/*chenl start*/
function deleteMyRecommend(objId,recommendType,serverpath){
	if(confirm("确实要删除吗?")){
		$.ajax({
		        type: "post",
		        dataType: "json",
		        url: serverpath+"/ajax/operation/deleteUserRecommend.action",
		        data: "recommendid="+objId+"&recommendType="+recommendType,
		        success: function(root){ 
		            if(root == "true"){
		            	common_a_div("删除成功！");
		            	pageAjaxUcenter('myrecommend_div_'+recommendType,'current_page=1&restype='+recommendType,serverpath+'/operation/getRecommendList.action',recommendType);
		            	//location.href=serverpath+"/usercenter/recommend.3.jsp?page_at=recommend";
		            }else{
		            	common_a_div("删除失败");
		            }
		        }
		 });
	}
	
}

//专题加载更多
function loadztmore(obj){
	 var page = $("#page").val(); 
	 var pushid = $("#pushid").val(); 
	 var resType = $("#resType").val(); 
	 var allcount = $("#allcount").val();
	 $.ajax({
	        type: "post",
	        dataType: "json",
	        url: obj+"/ajax/apps/loadmore.action",
	        data: "page="+page+"&pushid="+pushid+"&resType="+resType+"&allcount="+allcount,
	        success: function(root){
	        	var html = root;
	            if(html==""){
	            	$("#moreinfo").hide();
	            }else{
	            	$("#info").append(html);
	            	var nextpage = page+1;
	            	$("#page").val(nextpage); 
	            }
	        }
	 }); 
}

function loadActivemore(obj){
	 var page = $("#page").val(); 
	 var pushid = $("#pushid").val(); 
	 var resType = $("#resType").val(); 
	 var allcount = $("#allcount").val();
	 $.ajax({
	        type: "post",
	        dataType: "json",
	        url: obj+"/ajax/apps/loadActivemore.action",
	        data: "page="+page+"&pushid="+pushid+"&resType="+resType+"&allcount="+allcount,
	        success: function(root){
	        	var html = root;
	            if(html==""){
	            	$("#moreinfo").hide();
	            }else{
	            	$("#info").append(html);
	            	var nextpage = page+1;
	            	$("#page").val(nextpage); 
	            }
	        }
	 }); 
}

//专题详细页加载更多
function loaddetailmore(obj){
	 var page = $("#page").val(); 
	 var pushid = $("#pushid").val(); 
	 var allcount = $("#allcount").val();
	 $.ajax({
	        type: "post",
	        dataType: "json",
	        url: obj+"/ajax/apps/loadMoreDetail.action",
	        data: "page="+page+"&pushid="+pushid+"&allcount="+allcount,
	        success: function(root){
	        	var html = root;
	            if(html==""){
	            	$("#moredetailinfo").hide();
	            }else{
	            	$("#zhuanti_detail_list_div").append(html);
	            	var nextpage = page+1;
	            	$("#page").val(nextpage); 
	            	if(page==allcount){
	            		$("#moredetailinfo").hide();
	            	}
	            }
	        }
	 }); 
}

//评论列表加载更多
function loadmorecomment(serverpath,obj){
	 var page = $("#currPage_comment").val(); 
	 var rescode = $("#comment_rescode").val(); 
	 var allcount = $("#comment_allcount").val();
	 $.ajax({
	        type: "post",
	        dataType: "json",
	        url: serverpath+"/ajax/comment/getMoreComments.action",
	        data: "currPage="+page+"&resourceCode="+rescode+"&allcount="+allcount+"&pageSize="+obj,
	        success: function(root){
	        	var html = root;
	            if(html==""){
	            	$("#morecommentdiv").hide();
	            }else{
	            	$("#clistdiv").append(html);
	            	var nextpage = parseInt(page)+1;
	            	$("#currPage_comment").val(nextpage); 
	            	if(page==allcount){
	            		$("#morecommentdiv").hide();
	            	}
	            }
	        }
	 }); 
}
/*chenl end*/



/*heye start*/
function doCancelOrderPopWin(orderName,orderTariff,orderId,path,orderType){
	document.getElementById("doCancelOrder").disabled=false;
	$("#orderN").html(orderName);
	if(orderTariff == ''||orderTariff == 'null'){
		$("label:eq(1)").hide();
	}else{
		$("#orderT").html(orderTariff);
	}
	$("#orderId").val(orderId);
	if(orderType == "6"){
		$(".pop_cover").show();
		$("#i_o_business").show();
		//$(".pop_win").hide();
		$("#orderN1").html(orderName);
		$("#desc1").html("<br/>抱歉,此业务暂不能在线退订,请拨打<br/>联通客服电话10010人工受理。");
	}else{
		$("#orderId").val(orderId);
		changeImageCode(path);
		$(".pop_cover").show();
		$(".pop_win").show();
		$("#inputCode").val("");
		$("#resType").val(orderType);
		$("#desc").html("");
	}
}

function doCancelOrder(serverpath){
	var orderId = $("#orderId").val();
	var resType = $("#resType").val();
	var inputCode = $("#inputCode").val();
	if(null == inputCode || "" == inputCode || undefined == inputCode){
		$("#desc").html("验证码不能为空");
		return false;
	}
 
	document.getElementById("doCancelOrder").disabled=true;
	$("#desc").html("正在处理中...请稍候");  
	jQuery.getJSON(serverpath+"/ajax/operation/doCancelOrderForAjax.action?jsoncallback=?",
    	    {orderId:orderId,inputCode:inputCode},function(data){
    	        var status = data.resultCode;
    	        var promptMessage = data.promptMessage; 
    	        
    	        if("errorCode" == status){
    	        	$("#desc").html(promptMessage);
                	document.getElementById("doCancelOrder").value="退订";
            		document.getElementById("doCancelOrder").disabled=false;
    	        }else{
    	        	//$("#desc").html("订购失败，请重新试一下");
                	$("#desc").html(promptMessage);
                	changeImageCode(serverpath);
                	document.getElementById("doCancelOrder").value="退订";
                	document.getElementById("doCancelOrder").disabled=true;
                	document.getElementById("orderfreeCode").disabled=true; 
                	$("#pop_win_input").val("p_w_reload");
                	/*setTimeout(function(){
    	        		$(".pop_cover").hide();
    	        		$(".pop_win").hide();
    	        		$("#inputCode").val("");
    	        		location.reload();
                	},5000);*/
                	//pageAjax('icenter_orderlist_div','current_page=1&icenter_order_type='+resType,serverpath+'/operation/queryOrderResources.action');

    	        }
    	    }); 
}

function addFriend(serverpath){
	var friendMobile = $("#friendMobile").val();
	var friendName = $("#friendName").val();
	var zz=/^0{0,1}(13[0-9]|15[0-9]|18[0-9])[0-9]{8}$/;
	if(friendMobile == ""){
		common_a_div("请输入好友手机号");
	}else if(zz.test(friendMobile)==false || friendMobile.length<11){
		common_a_div("手机号输入有误，请重新输入");
	}else if(friendName == ""){
		common_a_div("请输入好友备注名");
	}else{
		$.ajax({
	        type: "post",
	        dataType: "json",
	        url: serverpath+"/ajax/operation/saveUserFriend.action",
	        data: "userFriendMobile="+friendMobile+"&userFriendContent="+friendName,
	        success: function(root){
	            if(root == "success"){
	            	common_a_div("添加成功！");
	            	location.href=serverpath+"/usercenter/friend.3.jsp?page_at=friend";  
	            }else{
	            	common_a_div(root);
	            }
	        }
	   }); 
	}
}

function pop_win_close(){
	var is_reload=$("#pop_win_input").val();
	if("p_w_reload"==is_reload){
		location.reload();
	}
	$(".pop_cover").hide();
	$(".pop_win").hide(); 
	$("#pop_win_input").val("");
}

function inviteFriend(serverpath){
	var friendMobile = $("#friendMobile").val();
	var zz=/^0{0,1}(13[0-9]|15[0-9]|18[0-9])[0-9]{8}$/;
	if(friendMobile == ""){
		common_a_div("请输入好友手机号");
	}else if(zz.test(friendMobile)==false || friendMobile.length<11){
		common_a_div("手机号输入有误，请重新输入");
	}else{
//		$.post(serverpath+"/ajax/operation/requestInviteFriend.action",{
//			"userFriend.userFriendMobile":friendMobile
//		},function(value){
//			if(value == "success"){
//				common_a_div("已成功发送邀请信息");
//			}else{
//				common_a_div("邀请失败！请联系管理员");
//			}
//		});
		$.ajax({
	        type: "post",
	        dataType: "json",
	        url: serverpath+"/ajax/operation/requestInviteFriend.action",
	        data: "friendMobile="+friendMobile,
	        success: function(root){
	            if(root == "success"){
	            	common_a_div("邀请信息已发送！");
	            }else{
	            	common_a_div(root); 
	            }
	        }
	   });
	}
}

function doOrderPopWin(orderName,orderTariff,orderId,resType,columnId,path){
	//如果传递过来的columnId2=list的话，那么是在列表页存在的该功能，只有一个参数。
	if(orderId == 'radio'){
		var checkResId = $('input:radio[name="v_zf"]:checked').val();
		//var checkResName = $('input:radio[name="v_zf"]:checked').html();
		var checkResName = $('input:radio[name="v_zf"]:checked').siblings("a").html(); 
		if(checkResId == undefined){
			common_a_div("请选择要订购的产品");
			return false;
		}else{
			orderId = checkResId;
			orderName = checkResName;
		}
	}
	document.getElementById("doOrder").disabled=false;
	$("#orderN").html(orderName);
	if(orderTariff == ''){
		$("label:eq(1)").hide();
	}else{
		$("#orderT").html(orderTariff);
	}
	$("#orderId").val(orderId);
	$("#columnId").val(columnId);
	$("#resType").val(resType);
	$("#spProductName").val(orderName);
	changeImageCode(path);
	$(".pop_cover").show();
	$(".pop_win").show();
	$("#inputCode").val("");
	$("#desc").html("");
}

//订购
function doOrder(serverpath){
	var resId = $("#orderId").val();
	var resType = $("#resType").val();
	var columnId = $("#columnId").val();
	var inputCode = $("#inputCode").val();
	var spProductName =  $("#spProductName").val();
	var flag = $("#flag").val();
	if(null == inputCode || "" == inputCode || undefined == inputCode){
		$("#desc").html("验证码不能为空");
		return false;
	}
	 
	document.getElementById("doOrder").disabled=true;
	$("#desc").html("正在处理中...请稍候"); 
    jQuery.getJSON(serverpath+"/ajax/operation/doOrderResources.action?jsoncallback=?",
    	    {resourcesId:resId,spProductName:spProductName,resType:resType,columnId:columnId,inputCode:inputCode},function(data){
    	        var status = data.resultCode;
    	        var promptMessage = data.promptMessage; 
    	        if("errorCode" == status){
    	        	$("#desc").html(promptMessage); 
            		document.getElementById("doOrder").value="订购";
            		document.getElementById("doOrder").disabled=false;
    	        }else{ 
                	$("#desc").html(promptMessage);
                	changeImageCode(serverpath);
                	$("#pop_win_input").val("p_w_reload");
                	/*setTimeout(function(){
                		$(".pop_cover").hide();
                		$(".pop_win").hide();
                    },5000);*/
                	document.getElementById("doOrder").value="订购";
                	document.getElementById("doOrder").disabled=true; 
                	document.getElementById("orderfreeCode").disabled=true; 
                	if("0" ==status && flag == "1" && (resId == "211032" || resId == "48168" || resId == "48166" || resId == "48164" || resId == "48154" || resId == "48156")){
            			//存入日志
            			$.ajax({
            		        type: "post",
            		        dataType: "json",
            		        url: serverpath+"/ajax/operation/addLog.action",
            		        data: "resourcesId="+resId+"&orderName="+spProductName,
            				success: function(result){
    		     			      window.location.href = serverpath+"/component/huodong/summer/gift.jsp?resId="+resId;
    		     			      return;
            				}
            			});
                	}
    	        }
    	    });  
}

function isToOrder(serverpath,orderId,orderName,orderTariff,resType,columnId,islogin,url1,resourceCode,columnId2){
	if(islogin == 'false'){
		window.location.href = serverpath+"/login/login.3.jsp?url1="+url1+"&url2="+resourceCode+"&url3="+columnId2;
	}else{
		if(orderId == 'radio'){
			var checkResId = $('input:radio[name="v_zf"]:checked').val(); 
			var checkResName = $('input:radio[name="v_zf"]:checked').siblings("a").html(); 
			if(checkResId == undefined){
				common_a_div("请选择要订购的产品");
				return false;
			}else{
				orderId = checkResId;
				orderName = checkResName;
			}
			console.log(checkResName);
		} 
		
		$("#orderN").html(orderName);
		$.ajax({
	        type: "post",
	        dataType: "json",
	        url: serverpath+"/ajax/operation/isOrder.action",
	        data: "resourcesId="+orderId,
	        success: function(root){
	        	if(root == "true"){
	        		common_a_div("您已订购");
	        	}else{
	        		doOrderPopWin(orderName,orderTariff,orderId,resType,columnId,serverpath);
	            }
	        }
	   });
	   //doOrderPopWin(orderName,orderTariff,orderId,resType,columnId,serverpath);
	}
}

function isCollect(serverpath,rescode,restype,columnid,islogin,url1,url2){
	if(islogin == 'false'){
		window.location.href = serverpath+"/login/login.3.jsp?url1="+url1+"&url2="+url2;
	}else{
		$.ajax({
	        type: "post",
	        dataType: "json",
	        url: serverpath+"/ajax/operation/isCollect.action",
	        data: "resourcesId="+rescode+"&resType="+restype,
	        success: function(root){
	        	if(root == "true"){
	        		common_a_div("您已收藏");
	        		return false;
	        	}else{
	        		collect(serverpath,rescode,restype,columnid,url1,url2);
	            }
	        }
	   });
	}
	
}

/*heye end*/

/*jinh start*/
//collect operate in detail page
/*收藏*/
/*
* original js in line 210 of wowanjia.js 
*/
/*$("#collect").click(function(){
	$(".pop_cover").show();
	$(".c_pop").show();
});*/
function collect(serverpath,rescode,restype,columnid,url1,url2){
	 if(null == rescode || "" == rescode || undefined == rescode){ 
		 return false;
	 }else{
		 $.ajax({
			url:serverpath+"/ajax/operation/doCollectResource.action",
			type:"post",
			data:"resourcesId="+rescode+"&resType="+restype+"&columnId="+columnid,
			async:false,
			dataType:"json",
			success:function (root){   
			if(root == "success"){
				common_a_div("收藏成功，您可以进入个人中心进行管理。"); 
				window.location.href=window.location.href;
			}else{
				common_a_div("收藏失败，请稍候再试。"); 
			}	
		}
	 }); 
	}  
}

/*客服专区提交问题*/
function question(serverpath,is_q_login){
	 if("true" == is_q_login){
		 var question_content = $("#add_ser_question").val();
		 if(null == question_content || "" == question_content || undefined == question_content){ 
			 common_a_div("请输入问题"); 
			 return false;
		 }else if(question_content.length < 3){
			 common_a_div("输入的问题不能少于3个字符，请重新输入"); 
			 return false;
		 }else if(question_content.length > 100){
			 common_a_div("输入的问题不能超过100个字符，请重新输入"); 
			 return false;
		 }else{  
			 $.ajax({
				url:serverpath+"/ajax/operation/addServiceQuestion.action",
				type:"post",
				data:"question_content="+question_content,
				async:false,
				dataType:"json",
				success:function (root){   
				if(root == "success"){
					common_a_div("问题提交成功"); 
					$("#add_ser_question").val("");
					return true;
				}else{
					common_a_div(root); 
				   	return false;
				}	
			}
		 }); 
		}  
	 }else{
		 var alink =serverpath+"/login/login.3.jsp";
		 common_atime_div("此功能需要登录后使用，请先登录",3000,alink);
	 }
}
/*jinh end*/










/***************yuanyu start************************/

//用户退出
function userQuit(serverpath){  
    $.ajax({
	       type: "post",
	       dataType: "json",
	       url: serverpath+"/ajax/account/requestQuit.action", 
		   success: function(root){  
		       //if(root == "success"){   
		       		location.href=serverpath+"/index.3.jsp";
		     //  }else{ 
		    	//    common_a_div("退出失败！");
		       //}
	       } 
		}); 
}

/***************yuanyu end************************/
/***************lixiu start************************/
//用户签到
function checkIn(serverpath){
	var isCheck = $("#checkintext").html();
	$("#checkintext").html("已签到");
	//请求用户签到
 	$.ajax({
	       type: "post",
	       dataType: "json",
	       url: serverpath+"/ajax/operation/userCheckIn.action", 
		   success: function(root){
				if(root == "fail"){
					common_a_div("对不起,签到失败\n记得明日再来签到哟,获取更多魔法币");
				}else{
 					//查询魔法币
				 	$.ajax({
					       type: "post",
					       dataType: "json",
					       url: serverpath+"/ajax/operation/getMagicCoinsAmount.action", 
						   success: function(magiccoins){
				 				$("#magicamount").html(magiccoins);
					       } 
						}); 
				 	common_a_div(root+"\n记得明日再来签到哟,获取更多魔法币");
				}
	       } 
		}); 
}
function orderSumbit(serverpath,flag){
	var cked=$(".packages input:checked");
	var ckNum=cked.length;
	var str=document.getElementsByName("giveres");
	var objarray=str.length;
	var resourceids="";
	for (i=0;i<objarray;i++){
	  if(str[i].checked == true){
		  resourceids+=str[i].value+",";
	  }
	}
	if(resourceids == ""){
	  $(".pageCover,.giftWinError").show();
		 $("#okone").css({display:"none"});
		 $("#oktwo").css({display:"none"});
		 $("#okthree").css({display:"none"});
	  return;
	}else{
		  $.ajax({
		        type: "post",
		        dataType: "json",
		        url: serverpath+"/ajax/operation/givebusiness.action",
		        data: "resourceids="+resourceids+"&againflag="+flag,
		        success: function(root){
					if(root.indexOf("tishi")!=-1){//是否放弃赠送次数(可以赠送4次只选择了2次其他的将放弃)
			        	$("#giftName1").html(root.replace("tishi",""));
						$(".pageCover,.giftWinOk").show();
						 $("#okone").css({display:"none"});
						 $("#oktwo").css({display:"block"});
						 $("#okthree").css({display:"none"});
			        }else if(root.indexOf("success")!=-1){
			        	$("#giftName1").html(root.replace("success",""));
						$(".pageCover,.giftWinOk").show();
						 $("#oktwo").css({display:"none"});
						 $("#okone").css({display:"none"});
						 $("#okthree").css({display:"block"});
			        }else{
			        	$("#giftName1").html(root);
						$(".pageCover,.giftWinOk").show();
						 $("#okone").css({display:"block"});
						 $("#oktwo").css({display:"none"});
						 $("#okthree").css({display:"none"});
			        }
				}
			});
	}
}

/***************lixiu end************************/
